#include <string>

#include <gtest/gtest.h>

#include "echo.pb.h"

using namespace std;
using namespace google::protobuf;
using namespace testing;

const int BufferLength = 100

/*测试案例：测试序列化请求*/
TEST(MessageUtilsTest, SerializeRequestTest)
{
  EchoParameter param;
  param.set_msg("Hello,this is client");
  BaseChannel channel;
  const MethodDescriptor &descriptor = getMethodDescriptor("echo");
  string requestData1 = channel.serializeRequest(descriptor, param);

  string requestData2;
  channel.serializeRequest(descriptor, param, requestData2);

  void *requestData3 = new char[BufferLength];
  channel.serializeRequest(descriptor, param, requestData3, BufferLength);
  
  ASSERT_STREQ(requestData1.c_str(), requestData2.c_str());
  ASSERT_STREQ(requestData1.c_str(), requestData3);
}
